﻿<%@ Page Title="Attribute" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Attribute.aspx.cs" Inherits="ColorApplication.color.Attribute" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="adminContent">
        <h2>Attribute
        </h2>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div id="modalPage" runat="server" class="modalPage">
                    <div class="modalBackground">
                    </div>
                    <div class="modalContainer">
                        <div class="modal">
                            <table>
                                <tr>
                                    <td align="center">
                                        <div style="background-color: White; border-radius: 5px; color: black; height: 47px;
                                            padding-top: 5px;">
                                            Please Wait...
                                        <br />
                                            <img src="../Images/preloader.gif" />
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="ErrorLabel" runat="server" CssClass="failureNotification"></asp:Label>
                <asp:Label ID="SuccesLabel" runat="server" CssClass="successNotification"></asp:Label>
                <asp:DetailsView ID="AttributeDetailsView" runat="server" Width="100%"
                    AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="AttributeDetailsviewSqlDataSource"
                    DefaultMode="Insert" OnItemInserted="AttributeDetailsView_ItemInserted" OnItemUpdated="AttributeDetailsView_ItemUpdated"
                    OnItemInserting="AttributeDetailsView_ItemInserting" OnItemUpdating="AttributeDetailsView_ItemUpdating">
                    <Fields>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:TemplateField HeaderText="Description" SortExpression="Description">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditDescriptionTextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="EditDescriptionRequiredFieldValidator1" runat="server"
                                    ControlToValidate="EditDescriptionTextBox1" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="Description is required."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertDescriptionTextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="InsertDescriptionRequiredFieldValidator1" runat="server"
                                    ControlToValidate="InsertDescriptionTextBox1" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Description is required."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Direction" SortExpression="Direction">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditDropDownList" runat="server" Width="142px" DataSourceID="AttributeTypeSqlDataSource"
                                    DataTextField="Direction" DataValueField="Id" SelectedValue='<%# Bind("Direction") %>'>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertDropDownList" runat="server" Width="142px" DataSourceID="AttributeTypeSqlDataSource"
                                    DataTextField="Direction" DataValueField="Id" SelectedValue='<%# Bind("Direction") %>'>
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Direction") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
                    </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource ID="AttributeDetailsviewSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" InsertCommand="InsertAttributesInsert"
                    InsertCommandType="StoredProcedure" SelectCommand="GetAttributesSelect" SelectCommandType="StoredProcedure"
                    UpdateCommand="UpdateAttributesUpdate" UpdateCommandType="StoredProcedure">
                    <InsertParameters>
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="Direction" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="AttributeGridView" Name="Id" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="Direction" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="AttributeTypeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    SelectCommand="SELECT * FROM [AttributeType]"></asp:SqlDataSource>
                <br />
                <br />
                <table>
                    <tr>
                        <td>Search By Description :
                        </td>
                        <td>
                            <asp:TextBox ID="SearchDescriptionTextBox" AutoPostBack="true" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <br />
                <asp:GridView ID="AttributeGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
                    DataSourceID="AttributeGridSqlDataSource" Width="100%" OnRowDataBound="AttributeGridView_RowDataBound"
                    OnRowDeleting="AttributeGridView_RowDeleting" OnSelectedIndexChanged="AttributeGridView_SelectedIndexChanged"
                    AllowSorting="True">
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <asp:TemplateField HeaderText="Direction" SortExpression="Direction">
                            <ItemTemplate>
                                <asp:Label ID="lblDirection" runat="server" Text='<%# Bind("Direction") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                        <asp:TemplateField HeaderText="Color Attribute">
                            <ItemTemplate>
                                <asp:HyperLink ID="ColorAttributeHyperLink" runat="server" NavigateUrl='<%# "~/color/ColorsAttribute.aspx?AttributeId=" +Eval("Id") %>'
                                    Text="Color"></asp:HyperLink>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Families">
                            <ItemTemplate>
                                <asp:HyperLink ID="FamiliesHyperLink" runat="server" NavigateUrl='<%# "~/color/AttributeXAttributefamilies.aspx?AttributeId=" +Eval("Id") %>'
                                    Text="Families"></asp:HyperLink>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="AttributeGridSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    DeleteCommand="DeleteAttributesDelete" DeleteCommandType="StoredProcedure" SelectCommand="GetSearchByDescriptionAttributesSelect"
                    SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="False">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="SearchDescriptionTextBox" PropertyName="Text" Name="Description"
                            Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
